package com.le.tester.book.effectivejava3rdchinese.secondReading.l02;

/**
 * createTime：2024-08-02 10:27
 * description：当构造方法参数过多
 */
public class NutritionFactsConstructor {

    private final int servingSize;

    private final int servings;

    private final int calories;

    private final int fat;

    private final int sodium;

    private final int carbohydrate;


    //使用构造方法来初始化参数
    public NutritionFactsConstructor(int servingSize, int servings) {
        this(servingSize, servings, 0);
    }

    public NutritionFactsConstructor(int servingSize, int servings, int calories) {
        this(servingSize, servings, calories, 0);
    }

    public NutritionFactsConstructor(int servingSize, int servings, int calories, int fat) {
        this(servingSize, servings, calories, fat, 0);
    }

    public NutritionFactsConstructor(int servingSize, int servings, int calories, int fat, int sodium) {
        this(servingSize, servings, calories, fat, sodium, 0);
    }

    public NutritionFactsConstructor(int servingSize, int servings, int calories, int fat, int sodium, int carbohydrate) {
        this.servingSize = servingSize;
        this.servings = servings;
        this.calories = calories;
        this.fat = fat;
        this.sodium = sodium;
        this.carbohydrate = carbohydrate;
    }



}
